package com.fastshop.backup.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.fastshop.backup.entity.Admin;
import com.fastshop.backup.service.IAdminService;

/**
 * ���⡢��Ҫ˵��. <br>
 * ����ϸ˵��.
 * <p>
 * Copyright: Copyright (c) 2013-3-29 ����10:11:15
 * <p>
 * Company: ������lʮ�����ּ������޹�˾
 * <p>
 * 
 * @author wangpz@c-platform.com
 * @version 1.0.0
 */
@Controller
@RequestMapping(value = "/admin")
public class AdminController extends BaseController {

	@Resource
	IAdminService adminService;

	@RequestMapping(value = "/login.htm", method = RequestMethod.POST)
	public String login() {
		System.err.println("xxx");
		return "asdfasdfasd";
	}

	@RequestMapping(value = "/list.htm", method = RequestMethod.GET)
	public String list(Model model) {
		Admin admin = new Admin();
		admin.setId(111L);
		admin.setEmail("wangpinzhuang@126.com");
		List<Admin> list = new ArrayList<Admin>();
		list.add(admin);
		return "/admin/list";
	}

	@RequestMapping(value = "/showList.htm", method = RequestMethod.GET)
	public String showList() {
		System.err.println("showList...............");
		return "/test2";
	}

	public void getInfo() {
		// ��ȡ������
		SecurityContext secCtx = SecurityContextHolder.getContext();
		// ��ȡ��֤����
		Authentication auth = secCtx.getAuthentication();
		// ��ȡ��֤�����е��������
		Object principal = auth.getPrincipal();
		String userName = "";
		if (principal instanceof UserDetails) {
			userName = ((UserDetails) principal).getUsername();
		}
	}
}
